package com.ctaa.ctaa.dto;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {

    private Boolean success;

    private String message;

    private Integer code;

    private T data;


    public static <T> Result<T> success(String message, T data) {
        Result result = new Result();
        result.setSuccess(true);
        result.setData(data);
        result.setMessage(message);
        result.setCode(Enum.SUCCESS);
        return result;
    }

    public static <T> Result<T> success(String message) {
        Result result = new Result();
        result.setSuccess(true);
        result.setData(null);
        result.setMessage(message);
        result.setCode(Enum.SUCCESS);
        return result;
    }

    public static <T> Result<T> fail(String message) {
        Result result = new Result();
        result.setSuccess(false);
        result.setData(null);
        result.setMessage(message);
        result.setCode(Enum.FAIL);
        return result;
    }

}
